/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.solitaire.web.controller.api;

import com.medusa.gruul.common.core.annotation.EscapeLogin;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.common.data.tenant.ShopContextHolder;
import com.medusa.gruul.common.data.tenant.TenantContextHolder;
import com.medusa.gruul.solitaire.api.model.vo.api.ApiSolitaireActivityVo;
import com.medusa.gruul.solitaire.service.api.IApiSolitaireActivityService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 接龙信息controller
 * @author lcysike
 * @Date 2020-06-22
 */
@RestController
@RequestMapping("/api/weChat")
public class ApiSolitaireActivityController {

	@Autowired
	private IApiSolitaireActivityService apiSolitaireActivityService;

	@ApiOperation(value = "获取当前接龙活动信息")
	@GetMapping("/current/activity")
	@EscapeLogin
	public Result<ApiSolitaireActivityVo> getCurrentActivity() {
		return apiSolitaireActivityService.getCurrentActivity();
	}

	@ApiOperation(value = "获取单场接龙活动详细信息")
	@GetMapping("/get/activity/{activityId}")
	@EscapeLogin
	public Result<ApiSolitaireActivityVo> getCurrentActivityById(@ApiParam(value = "接龙活动id", required = true) @PathVariable("activityId") Long activityId) {
		return apiSolitaireActivityService.getCurrentActivityById(activityId);
	}

	@ApiOperation(value = "h5获取单场接龙活动详细信息")
	@GetMapping("/h5/get/activity")
	@EscapeLogin
	public Result<ApiSolitaireActivityVo> getH5CurrentActivityById(@ApiParam(value = "接龙活动id", required = true) @RequestParam Long activityId,
																   @ApiParam(value = "租户id", required = true) @RequestParam String tenantId,
																   @ApiParam(value = "店铺id", required = true) @RequestParam String shopId) {
		TenantContextHolder.setTenantId(tenantId);
		ShopContextHolder.setShopId(shopId);
		return apiSolitaireActivityService.getCurrentActivityById(activityId);
	}

	@ApiOperation(value = "转发当前接龙活动商品信息")
	@GetMapping("/current/activity/product/{activityId}")
	@EscapeLogin
	public Result getCurrentActivityProduct(@ApiParam(value = "接龙活动id", required = true) @PathVariable("activityId") Long activityId,
											@ApiParam(value = "接龙活动跳转路径", required = true) @RequestParam("path") String path) {
		return apiSolitaireActivityService.getCurrentActivityProduct(activityId, path);
	}

	@ApiOperation(value = "转发当前接龙信息")
	@GetMapping("/current/activity/record/{activityId}")
	public Result getCurrentActivityRecord(@ApiParam(value = "接龙活动id", required = true) @PathVariable("activityId") Long activityId,
										   @ApiParam(value = "接龙活动跳转路径", required = true) @RequestParam("path") String path) {
		return apiSolitaireActivityService.getCurrentActivityRecord(activityId, path);
	}

	@ApiOperation(value = "根据商品获取当前参与的最新一场接龙活动信息")
	@GetMapping("get/activity/by/product/{productId}")
	@EscapeLogin
	public Result getActivityByProduct(@ApiParam(value = "商品id", required = true) @PathVariable("productId") Long productId) {
		return apiSolitaireActivityService.getActivityByProduct(productId);
	}
}

